clang  10.0.0svn
Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Friends | List of all members
clang::interp::ByteCodeExprGen< Emitter > Class Template Reference

Compilation context for expressions. More...

#include "/opt/doxygen-docs/src/llvm/tools/clang/lib/AST/Interp/ByteCodeExprGen.h"

Inheritance diagram for clang::interp::ByteCodeExprGen< Emitter >:
Inheritance graph
[legend]
Collaboration diagram for clang::interp::ByteCodeExprGen< Emitter >:
Collaboration graph
[legend]

Public Member Functions

template<typename... Tys>
 ByteCodeExprGen (Context &Ctx, Program &P, Tys &&... Args)
 Initializes the compiler and the backend emitter. More...
 
bool VisitCastExpr (const CastExpr *E)
 
bool VisitIntegerLiteral (const IntegerLiteral *E)
 
bool VisitParenExpr (const ParenExpr *E)
 
bool VisitBinaryOperator (const BinaryOperator *E)
 
- Public Member Functions inherited from clang::StmtVisitorBase< llvm::make_const_ptr, ByteCodeExprGen< Emitter >, bool, ParamTys... >
bool Visit (PTR(Stmt) S, ParamTys... P)
 
 BINOP_FALLBACK (PtrMemD) BINOP_FALLBACK(PtrMemI) BINOP_FALLBACK(Mul) BINOP_FALLBACK(Div) BINOP_FALLBACK(Rem) BINOP_FALLBACK(Add) BINOP_FALLBACK(Sub) BINOP_FALLBACK(Shl) BINOP_FALLBACK(LT) BINOP_FALLBACK(GT) BINOP_FALLBACK(LE) BINOP_FALLBACK(GE) BINOP_FALLBACK(EQ) BINOP_FALLBACK(NE) BINOP_FALLBACK(And) BINOP_FALLBACK(Xor) BINOP_FALLBACK(Or) BINOP_FALLBACK(LAnd) BINOP_FALLBACK(LOr) CAO_FALLBACK(MulAssign) CAO_FALLBACK(DivAssign) CAO_FALLBACK(RemAssign) CAO_FALLBACK(AddAssign) CAO_FALLBACK(SubAssign) CAO_FALLBACK(ShlAssign) CAO_FALLBACK(ShrAssign) CAO_FALLBACK(AndAssign) CAO_FALLBACK(OrAssign) UNARYOP_FALLBACK(PostInc) UNARYOP_FALLBACK(PostDec) UNARYOP_FALLBACK(PreInc) UNARYOP_FALLBACK(PreDec) UNARYOP_FALLBACK(AddrOf) UNARYOP_FALLBACK(Deref) UNARYOP_FALLBACK(Plus) UNARYOP_FALLBACK(Minus) UNARYOP_FALLBACK(Not) UNARYOP_FALLBACK(LNot) UNARYOP_FALLBACK(Real) UNARYOP_FALLBACK(Imag) UNARYOP_FALLBACK(Extension) UNARYOP_FALLBACK(Coawait) bool VisitStmt(PTR(Stmt) Node
 

Protected Types

using NullaryFn = bool(ByteCodeExprGen::*)(const SourceInfo &)
 
using UnaryFn = bool(ByteCodeExprGen::*)(PrimType, const SourceInfo &)
 
using BinaryFn = bool(ByteCodeExprGen::*)(PrimType, PrimType, const SourceInfo &)
 
using LabelTy = typename Emitter::LabelTy
 
using AddrTy = typename Emitter::AddrTy
 
using InitFnRef = std::function< bool()>
 

Protected Member Functions

bool visitExpr (const Expr *E) override
 
bool visitDecl (const VarDecl *VD) override
 
void emitCleanup ()
 Emits scope cleanup instructions. More...
 
const RecordTypegetRecordTy (QualType Ty)
 Returns a record type from a record or pointer type. More...
 
RecordgetRecord (QualType Ty)
 Returns a record from a record or pointer type. More...
 
RecordgetRecord (const RecordDecl *RD)
 
unsigned getIntWidth (QualType Ty)
 Returns the size int bits of an integer. More...
 
unsigned getCharBit () const
 Returns the value of CHAR_BIT. More...
 
llvm::Optional< PrimTypeclassify (const Expr *E) const
 Classifies a type. More...
 
llvm::Optional< PrimTypeclassify (QualType Ty) const
 
bool needsAdjust (QualType Ty) const
 Checks if a pointer needs adjustment. More...
 
PrimType classifyPrim (QualType Ty) const
 Classifies a known primitive type. More...
 
bool discard (const Expr *E)
 Evaluates an expression for side effects and discards the result. More...
 
bool visit (const Expr *E)
 Evaluates an expression and places result on stack. More...
 
bool visitInitializer (const Expr *E, InitFnRef GenPtr)
 Compiles an initializer for a local. More...
 
bool visitBool (const Expr *E)
 Visits an expression and converts it to a boolean. More...
 
bool visitLocalInitializer (const Expr *Init, unsigned I)
 Visits an initializer for a local. More...
 
bool visitGlobalInitializer (const Expr *Init, unsigned I)
 Visits an initializer for a global. More...
 
bool visitThisInitializer (const Expr *I)
 Visits a delegated initializer. More...
 
unsigned allocateLocalPrimitive (DeclTy &&Decl, PrimType Ty, bool IsMutable, bool IsExtended=false)
 Creates a local primitive value. More...
 
llvm::Optional< unsigned > allocateLocal (DeclTy &&Decl, bool IsExtended=false)
 Allocates a space storing a local given its type. More...
 

Protected Attributes

ContextCtx
 Current compilation context. More...
 
ProgramP
 Program to link to. More...
 
llvm::DenseMap< const ValueDecl *, Scope::LocalLocals
 Variable to storage mapping. More...
 
llvm::DenseMap< const OpaqueValueExpr *, unsigned > OpaqueExprs
 OpaqueValueExpr to location mapping. More...
 
VariableScope< Emitter > * VarScope = nullptr
 Current scope. More...
 
llvm::Optional< uint64_t > ArrayIndex
 Current argument index. More...
 
bool DiscardResult = false
 Flag indicating if return value is to be discarded. More...
 
llvm::Optional< InitFnRefInitFn = {}
 Expression being initialized. More...
 

Friends

class VariableScope< Emitter >
 
class LocalScope< Emitter >
 
class RecordScope< Emitter >
 
class DeclScope< Emitter >
 
class OptionScope< Emitter >
 

Additional Inherited Members

- Public Attributes inherited from clang::StmtVisitorBase< llvm::make_const_ptr, ByteCodeExprGen< Emitter >, bool, ParamTys... >
ParamTys P
 

Detailed Description

template<class Emitter>
class clang::interp::ByteCodeExprGen< Emitter >

Compilation context for expressions.

Definition at line 41 of file ByteCodeExprGen.h.

Member Typedef Documentation

◆ AddrTy

template<class Emitter>
using clang::interp::ByteCodeExprGen< Emitter >::AddrTy = typename Emitter::AddrTy
protected

Definition at line 52 of file ByteCodeExprGen.h.

◆ BinaryFn

template<class Emitter>
using clang::interp::ByteCodeExprGen< Emitter >::BinaryFn = bool (ByteCodeExprGen::*)(PrimType, PrimType, const SourceInfo &)
protected

Definition at line 48 of file ByteCodeExprGen.h.

◆ InitFnRef

template<class Emitter>
using clang::interp::ByteCodeExprGen< Emitter >::InitFnRef = std::function<bool()>
protected

Definition at line 55 of file ByteCodeExprGen.h.

◆ LabelTy

template<class Emitter>
using clang::interp::ByteCodeExprGen< Emitter >::LabelTy = typename Emitter::LabelTy
protected

Definition at line 51 of file ByteCodeExprGen.h.

◆ NullaryFn

template<class Emitter>
using clang::interp::ByteCodeExprGen< Emitter >::NullaryFn = bool (ByteCodeExprGen::*)(const SourceInfo &)
protected

Definition at line 45 of file ByteCodeExprGen.h.

◆ UnaryFn

template<class Emitter>
using clang::interp::ByteCodeExprGen< Emitter >::UnaryFn = bool (ByteCodeExprGen::*)(PrimType, const SourceInfo &)
protected

Definition at line 46 of file ByteCodeExprGen.h.

Constructor & Destructor Documentation

◆ ByteCodeExprGen()

template<class Emitter>
template<typename... Tys>
clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen ( Context Ctx,
Program P,
Tys &&...  Args 
)
inline

Member Function Documentation

◆ allocateLocal()

template<class Emitter >
llvm::Optional< unsigned > ByteCodeExprGen::allocateLocal ( DeclTy &&  Decl,
bool  IsExtended = false 
)
protected

◆ allocateLocalPrimitive()

template<class Emitter >
unsigned ByteCodeExprGen::allocateLocalPrimitive ( DeclTy &&  Decl,
PrimType  Ty,
bool  IsMutable,
bool  IsExtended = false 
)
protected

Creates a local primitive value.

Definition at line 423 of file ByteCodeExprGen.cpp.

References clang::interp::Scope::Local::Offset, and P.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer().

◆ classify() [1/2]

template<class Emitter>
llvm::Optional<PrimType> clang::interp::ByteCodeExprGen< Emitter >::classify ( const Expr E) const
inlineprotected

◆ classify() [2/2]

template<class Emitter>
llvm::Optional<PrimType> clang::interp::ByteCodeExprGen< Emitter >::classify ( QualType  Ty) const
inlineprotected

Definition at line 105 of file ByteCodeExprGen.h.

References clang::interp::Context::classify().

◆ classifyPrim()

template<class Emitter>
PrimType clang::interp::ByteCodeExprGen< Emitter >::classifyPrim ( QualType  Ty) const
inlineprotected

◆ discard()

template<class Emitter >
bool ByteCodeExprGen::discard ( const Expr E)
protected

Evaluates an expression for side effects and discards the result.

Definition at line 209 of file ByteCodeExprGen.cpp.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().

◆ emitCleanup()

template<class Emitter >
void ByteCodeExprGen::emitCleanup ( )
protected

Emits scope cleanup instructions.

Definition at line 568 of file ByteCodeExprGen.cpp.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

◆ getCharBit()

template<class Emitter>
unsigned clang::interp::ByteCodeExprGen< Emitter >::getCharBit ( ) const
inlineprotected

◆ getIntWidth()

template<class Emitter>
unsigned clang::interp::ByteCodeExprGen< Emitter >::getIntWidth ( QualType  Ty)
inlineprotected

Returns the size int bits of an integer.

Definition at line 90 of file ByteCodeExprGen.h.

References clang::interp::Context::getASTContext(), and clang::ASTContext::getIntWidth().

◆ getRecord() [1/2]

template<class Emitter >
Record * ByteCodeExprGen::getRecord ( QualType  Ty)
protected

Returns a record from a record or pointer type.

Definition at line 506 of file ByteCodeExprGen.cpp.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

◆ getRecord() [2/2]

template<class Emitter >
Record * ByteCodeExprGen::getRecord ( const RecordDecl RD)
protected

Definition at line 514 of file ByteCodeExprGen.cpp.

References P.

◆ getRecordTy()

template<class Emitter >
const RecordType * ByteCodeExprGen::getRecordTy ( QualType  Ty)
protected

Returns a record type from a record or pointer type.

Definition at line 498 of file ByteCodeExprGen.cpp.

References clang::Type::getAs(), and clang::Type::getPointeeType().

Referenced by clang::interp::ByteCodeExprGen< Emitter >::ByteCodeExprGen().

◆ needsAdjust()

template<class Emitter>
bool clang::interp::ByteCodeExprGen< Emitter >::needsAdjust ( QualType  Ty) const
inlineprotected

Checks if a pointer needs adjustment.

Definition at line 110 of file ByteCodeExprGen.h.

◆ visit()

template<class Emitter >
bool ByteCodeExprGen::visit ( const Expr E)
protected

Evaluates an expression and places result on stack.

Definition at line 215 of file ByteCodeExprGen.cpp.

Referenced by clang::interp::ByteCodeExprGen< Emitter >::classifyPrim().

◆ VisitBinaryOperator()

template<class Emitter >
bool ByteCodeExprGen::VisitBinaryOperator ( const BinaryOperator E)

◆ visitBool()

template<class Emitter >
bool ByteCodeExprGen::visitBool ( const Expr E)
protected

◆ VisitCastExpr()

template<class Emitter >
bool ByteCodeExprGen::VisitCastExpr ( const CastExpr E)

◆ visitDecl()

template<class Emitter >
bool ByteCodeExprGen::visitDecl ( const VarDecl VD)
overrideprotected

◆ visitExpr()

template<class Emitter >
bool ByteCodeExprGen::visitExpr ( const Expr E)
overrideprotected

◆ visitGlobalInitializer()

template<class Emitter>
bool clang::interp::ByteCodeExprGen< Emitter >::visitGlobalInitializer ( const Expr Init,
unsigned  I 
)
inlineprotected

Visits an initializer for a global.

Definition at line 140 of file ByteCodeExprGen.h.

References clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().

◆ visitInitializer()

template<class Emitter >
bool ByteCodeExprGen::visitInitializer ( const Expr E,
InitFnRef  GenPtr 
)
protected

◆ VisitIntegerLiteral()

template<class Emitter >
bool ByteCodeExprGen::VisitIntegerLiteral ( const IntegerLiteral E)

◆ visitLocalInitializer()

template<class Emitter>
bool clang::interp::ByteCodeExprGen< Emitter >::visitLocalInitializer ( const Expr Init,
unsigned  I 
)
inlineprotected

Visits an initializer for a local.

Definition at line 133 of file ByteCodeExprGen.h.

References clang::interp::ByteCodeExprGen< Emitter >::visitInitializer().

◆ VisitParenExpr()

template<class Emitter >
bool ByteCodeExprGen::VisitParenExpr ( const ParenExpr E)

◆ visitThisInitializer()

template<class Emitter>
bool clang::interp::ByteCodeExprGen< Emitter >::visitThisInitializer ( const Expr I)
inlineprotected

Friends And Related Function Documentation

◆ DeclScope< Emitter >

template<class Emitter>
friend class DeclScope< Emitter >
friend

Definition at line 163 of file ByteCodeExprGen.h.

◆ LocalScope< Emitter >

template<class Emitter>
friend class LocalScope< Emitter >
friend

Definition at line 161 of file ByteCodeExprGen.h.

◆ OptionScope< Emitter >

template<class Emitter>
friend class OptionScope< Emitter >
friend

Definition at line 164 of file ByteCodeExprGen.h.

◆ RecordScope< Emitter >

template<class Emitter>
friend class RecordScope< Emitter >
friend

Definition at line 162 of file ByteCodeExprGen.h.

◆ VariableScope< Emitter >

template<class Emitter>
friend class VariableScope< Emitter >
friend

Definition at line 160 of file ByteCodeExprGen.h.

Member Data Documentation

◆ ArrayIndex

template<class Emitter>
llvm::Optional<uint64_t> clang::interp::ByteCodeExprGen< Emitter >::ArrayIndex
protected

Current argument index.

Definition at line 227 of file ByteCodeExprGen.h.

◆ Ctx

template<class Emitter>
Context& clang::interp::ByteCodeExprGen< Emitter >::Ctx
protected

Current compilation context.

Definition at line 58 of file ByteCodeExprGen.h.

◆ DiscardResult

template<class Emitter>
bool clang::interp::ByteCodeExprGen< Emitter >::DiscardResult = false
protected

Flag indicating if return value is to be discarded.

Definition at line 230 of file ByteCodeExprGen.h.

Referenced by clang::interp::OptionScope< Emitter >::OptionScope().

◆ InitFn

template<class Emitter>
llvm::Optional<InitFnRef> clang::interp::ByteCodeExprGen< Emitter >::InitFn = {}
protected

Expression being initialized.

Definition at line 233 of file ByteCodeExprGen.h.

Referenced by clang::interp::OptionScope< Emitter >::OptionScope().

◆ Locals

template<class Emitter>
llvm::DenseMap<const ValueDecl *, Scope::Local> clang::interp::ByteCodeExprGen< Emitter >::Locals
protected

Variable to storage mapping.

Definition at line 218 of file ByteCodeExprGen.h.

◆ OpaqueExprs

template<class Emitter>
llvm::DenseMap<const OpaqueValueExpr *, unsigned> clang::interp::ByteCodeExprGen< Emitter >::OpaqueExprs
protected

OpaqueValueExpr to location mapping.

Definition at line 221 of file ByteCodeExprGen.h.

◆ P

template<class Emitter>
Program& clang::interp::ByteCodeExprGen< Emitter >::P
protected

Program to link to.

Definition at line 60 of file ByteCodeExprGen.h.

◆ VarScope

template<class Emitter>
VariableScope<Emitter>* clang::interp::ByteCodeExprGen< Emitter >::VarScope = nullptr
protected

Current scope.

Definition at line 224 of file ByteCodeExprGen.h.

Referenced by clang::interp::VariableScope< Emitter >::VariableScope().


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