Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Public Member Functions | Static Public Member Functions | List of all members
Expr Class Referenceabstract

Expr is the abstract base class that defines the interface that all expression types must implement. More...

#include <expr.h>

Inheritance diagram for Expr:
Inheritance graph
[legend]
Collaboration diagram for Expr:
Collaboration graph
[legend]

Public Member Functions

 Expr (SourcePos p, unsigned scid)
 
virtual llvm::Value * GetValue (FunctionEmitContext *ctx) const =0
 
virtual llvm::Value * GetLValue (FunctionEmitContext *ctx) const
 
virtual const TypeGetType () const =0
 
virtual const TypeGetLValueType () const
 
virtual SymbolGetBaseSymbol () const
 
virtual std::pair< llvm::Constant *, bool > GetStorageConstant (const Type *type) const
 
virtual std::pair< llvm::Constant *, bool > GetConstant (const Type *type) const
 
virtual ExprOptimize ()=0
 
virtual ExprTypeCheck ()=0
 
virtual void Print () const =0
 
- Public Member Functions inherited from ASTNode
 ASTNode (SourcePos p, unsigned scid)
 
virtual ~ASTNode ()
 
virtual int EstimateCost () const =0
 
unsigned getValueID () const
 

Static Public Member Functions

static bool classof (Expr const *)
 
static bool classof (ASTNode const *N)
 
- Static Public Member Functions inherited from ASTNode
static bool classof (ASTNode const *)
 

Additional Inherited Members

- Public Types inherited from ASTNode
enum  ASTNodeTy {
  AddressOfExprID, AssignExprID, BinaryExprID, ConstExprID,
  DerefExprID, PtrDerefExprID, RefDerefExprID, ExprListID,
  FunctionCallExprID, FunctionSymbolExprID, IndexExprID, StructMemberExprID,
  VectorMemberExprID, NewExprID, NullPointerExprID, ReferenceExprID,
  SelectExprID, SizeOfExprID, SymbolExprID, SyncExprID,
  TypeCastExprID, UnaryExprID, MaxExprID, AssertStmtID,
  BreakStmtID, CaseStmtID, ContinueStmtID, DeclStmtID,
  DefaultStmtID, DeleteStmtID, DoStmtID, ExprStmtID,
  ForeachActiveStmtID, ForeachStmtID, ForeachUniqueStmtID, ForStmtID,
  GotoStmtID, IfStmtID, LabeledStmtID, PrintStmtID,
  ReturnStmtID, StmtListID, SwitchStmtID, UnmaskedStmtID
}
 
- Public Attributes inherited from ASTNode
SourcePos pos
 

Detailed Description

Expr is the abstract base class that defines the interface that all expression types must implement.

Definition at line 47 of file expr.h.

Constructor & Destructor Documentation

◆ Expr()

Expr::Expr ( SourcePos  p,
unsigned  scid 
)
inline

Definition at line 49 of file expr.h.

Member Function Documentation

◆ classof() [1/2]

static bool Expr::classof ( Expr const *  )
inlinestatic

Definition at line 51 of file expr.h.

◆ classof() [2/2]

static bool Expr::classof ( ASTNode const *  N)
inlinestatic

◆ GetBaseSymbol()

Symbol * Expr::GetBaseSymbol ( ) const
virtual

◆ GetConstant()

std::pair< llvm::Constant *, bool > Expr::GetConstant ( const Type type) const
virtual

If this is a constant expression that can be converted to a constant of the given type, this method should return the corresponding llvm::Constant value and a flag denoting if it's valid for multi-target compilation for use as an initializer of a global variable. Otherwise it should return the llvm::constant value as NULL.

Reimplemented in NullPointerExpr, FunctionSymbolExpr, SizeOfExpr, AddressOfExpr, TypeCastExpr, ConstExpr, ExprList, and BinaryExpr.

Definition at line 85 of file expr.cpp.

Referenced by classof(), BinaryExpr::classof(), ExprList::classof(), ConstExpr::classof(), TypeCastExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), FunctionSymbolExpr::classof(), NullPointerExpr::classof(), DeclStmt::EmitCode(), TypeCastExpr::GetConstant(), AddressOfExpr::GetConstant(), GetStorageConstant(), lGetBinaryExprStorageConstant(), and lGetExprListConstant().

◆ GetLValue()

llvm::Value * Expr::GetLValue ( FunctionEmitContext ctx) const
virtual

For expressions that can provide an lvalue (e.g. array indexing), this function should emit IR that computes the expression's lvalue and returns the corresponding llvm::Value. Expressions that can't provide an lvalue should leave this unimplemented; the default implementation returns NULL.

Reimplemented in VectorMemberExpr, SymbolExpr, DerefExpr, TypeCastExpr, MemberExpr, IndexExpr, and FunctionCallExpr.

Definition at line 73 of file expr.cpp.

Referenced by classof(), FunctionCallExpr::classof(), IndexExpr::classof(), MemberExpr::classof(), TypeCastExpr::classof(), DerefExpr::classof(), SymbolExpr::classof(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), AssignExpr::GetValue(), ReferenceExpr::GetValue(), AddressOfExpr::GetValue(), VectorMemberExpr::GetValue(), lEmitOpAssign(), and lEmitPrePostIncDec().

◆ GetLValueType()

const Type * Expr::GetLValueType ( ) const
virtual

◆ GetStorageConstant()

std::pair< llvm::Constant *, bool > Expr::GetStorageConstant ( const Type type) const
virtual

If this is a constant expression that can be converted to a constant of storage type of the given type, this method should return the corresponding llvm::Constant value and a flag denoting if it's valid for multi-target compilation for use as an initializer of a global variable. Otherwise it should return the llvm::constant value as NULL.

Reimplemented in ConstExpr, ExprList, and BinaryExpr.

Definition at line 84 of file expr.cpp.

References GetConstant().

Referenced by Module::AddGlobalVariable(), classof(), BinaryExpr::classof(), ExprList::classof(), ConstExpr::classof(), InitSymbol(), lGetBinaryExprStorageConstant(), and lGetExprListConstant().

◆ GetType()

virtual const Type* Expr::GetType ( ) const
pure virtual

Returns the Type of the expression.

Implemented in VectorMemberExpr, StructMemberExpr, NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, RefDerefExpr, PtrDerefExpr, ReferenceExpr, TypeCastExpr, ConstExpr, MemberExpr, IndexExpr, FunctionCallExpr, ExprList, SelectExpr, AssignExpr, BinaryExpr, and UnaryExpr.

Referenced by classof(), UnaryExpr::classof(), BinaryExpr::classof(), AssignExpr::classof(), SelectExpr::classof(), ExprList::classof(), FunctionCallExpr::classof(), IndexExpr::classof(), MemberExpr::classof(), ConstExpr::classof(), TypeCastExpr::classof(), ReferenceExpr::classof(), PtrDerefExpr::classof(), RefDerefExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), SyncExpr::classof(), NullPointerExpr::classof(), NewExpr::classof(), MemberExpr::create(), FunctionEmitContext::CurrentLanesReturned(), DeclStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), ReturnStmt::EmitCode(), SwitchStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), IfStmt::EstimateCost(), DoStmt::EstimateCost(), ForStmt::EstimateCost(), FunctionCallExpr::EstimateCost(), IndexExpr::EstimateCost(), SwitchStmt::EstimateCost(), PtrDerefExpr::EstimateCost(), FullResolveOverloads(), MemberExpr::getCandidateNearMatches(), TypeCastExpr::GetConstant(), AddressOfExpr::GetConstant(), SizeOfExpr::GetConstant(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), IndexExpr::GetLValueType(), ReferenceExpr::GetLValueType(), DerefExpr::GetLValueType(), AddressOfExpr::GetLValueType(), StructMemberExpr::GetLValueType(), VectorMemberExpr::GetLValueType(), StructMemberExpr::getStructType(), UnaryExpr::GetType(), BinaryExpr::GetType(), AssignExpr::GetType(), SelectExpr::GetType(), IndexExpr::GetType(), TypeCastExpr::GetType(), ReferenceExpr::GetType(), PtrDerefExpr::GetType(), RefDerefExpr::GetType(), AddressOfExpr::GetType(), StructMemberExpr::GetType(), BinaryExpr::GetValue(), AssignExpr::GetValue(), SelectExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), TypeCastExpr::GetValue(), ReferenceExpr::GetValue(), DerefExpr::GetValue(), AddressOfExpr::GetValue(), SizeOfExpr::GetValue(), VectorMemberExpr::GetValue(), InitSymbol(), lArrayToPointer(), lCanImproveVectorDivide(), lCheckAllOffSafety(), lCreateBinaryOperatorCall(), lDoTypeConv(), lEmitLogicalOp(), lEmitNegate(), lEmitOpAssign(), lEmitPrePostIncDec(), lEmitSelectExprCode(), lGetBinaryExprStorageConstant(), lGetFunctionType(), lIsAllIntZeros(), lIsDifficultShiftAmount(), lIsVaryingFor(), lProcessPrintArg(), DeclStmt::Optimize(), BinaryExpr::Optimize(), SizeOfExpr::Print(), IfStmt::TypeCheck(), UnaryExpr::TypeCheck(), DoStmt::TypeCheck(), BinaryExpr::TypeCheck(), ForStmt::TypeCheck(), AssignExpr::TypeCheck(), SelectExpr::TypeCheck(), FunctionCallExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), IndexExpr::TypeCheck(), SwitchStmt::TypeCheck(), TypeCastExpr::TypeCheck(), AssertStmt::TypeCheck(), DeleteStmt::TypeCheck(), PtrDerefExpr::TypeCheck(), RefDerefExpr::TypeCheck(), AddressOfExpr::TypeCheck(), NewExpr::TypeCheck(), TypeConvertExpr(), and VectorMemberExpr::VectorMemberExpr().

◆ GetValue()

virtual llvm::Value* Expr::GetValue ( FunctionEmitContext ctx) const
pure virtual

This is the main method for Expr implementations to implement. It should call methods in the FunctionEmitContext to emit LLVM IR instructions to the current basic block in order to generate an llvm::Value that represents the expression's value.

Implemented in VectorMemberExpr, NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, DerefExpr, ReferenceExpr, TypeCastExpr, ConstExpr, MemberExpr, IndexExpr, FunctionCallExpr, ExprList, SelectExpr, AssignExpr, BinaryExpr, and UnaryExpr.

Referenced by classof(), UnaryExpr::classof(), BinaryExpr::classof(), AssignExpr::classof(), SelectExpr::classof(), ExprList::classof(), FunctionCallExpr::classof(), IndexExpr::classof(), MemberExpr::classof(), ConstExpr::classof(), TypeCastExpr::classof(), ReferenceExpr::classof(), DerefExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), SyncExpr::classof(), NullPointerExpr::classof(), NewExpr::classof(), FunctionEmitContext::CurrentLanesReturned(), ExprStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), SwitchStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), IndexExpr::GetLValue(), MemberExpr::GetLValue(), DerefExpr::GetLValue(), UnaryExpr::GetValue(), BinaryExpr::GetValue(), AssignExpr::GetValue(), SelectExpr::GetValue(), FunctionCallExpr::GetValue(), IndexExpr::GetValue(), MemberExpr::GetValue(), TypeCastExpr::GetValue(), ReferenceExpr::GetValue(), DerefExpr::GetValue(), AddressOfExpr::GetValue(), NewExpr::GetValue(), VectorMemberExpr::GetValue(), InitSymbol(), lEmitLogicalOp(), lEmitNegate(), lEmitOpAssign(), lEmitPrePostIncDec(), lEmitSelectExprCode(), and lProcessPrintArg().

◆ Optimize()

virtual Expr* Expr::Optimize ( )
pure virtual

◆ Print()

virtual void Expr::Print ( ) const
pure virtual

◆ TypeCheck()

virtual Expr* Expr::TypeCheck ( )
pure virtual

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