Intel SPMD Program Compiler  1.9.1
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 llvm::Constant * 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 48 of file expr.h.

Constructor & Destructor Documentation

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

Definition at line 50 of file expr.h.

Member Function Documentation

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

Definition at line 52 of file expr.h.

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

Definition at line 53 of file expr.h.

References ASTNode::getValueID(), and ASTNode::MaxExprID.

Symbol * Expr::GetBaseSymbol ( ) const
virtual

For expressions that have values based on a symbol (e.g. regular symbol references, array indexing, etc.), this returns a pointer to that symbol.

Reimplemented in FunctionSymbolExpr, SymbolExpr, AddressOfExpr, DerefExpr, ReferenceExpr, TypeCastExpr, MemberExpr, and IndexExpr.

Definition at line 109 of file expr.cpp.

Referenced by IndexExpr::GetBaseSymbol(), MemberExpr::GetBaseSymbol(), TypeCastExpr::GetBaseSymbol(), ReferenceExpr::GetBaseSymbol(), DerefExpr::GetBaseSymbol(), AddressOfExpr::GetBaseSymbol(), AssignExpr::GetValue(), DerefExpr::GetValue(), and lEmitPrePostIncDec().

llvm::Constant * 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. Otherwise it should return NULL.

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

Definition at line 102 of file expr.cpp.

Referenced by Module::AddGlobalVariable(), DeclStmt::EmitCode(), ExprList::GetConstant(), TypeCastExpr::GetConstant(), AddressOfExpr::GetConstant(), and InitSymbol().

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 87 of file expr.cpp.

Referenced by IndexExpr::GetLValue(), MemberExpr::GetLValue(), AssignExpr::GetValue(), ReferenceExpr::GetValue(), AddressOfExpr::GetValue(), VectorMemberExpr::GetValue(), lEmitOpAssign(), and lEmitPrePostIncDec().

const Type * Expr::GetLValueType ( ) const
virtual
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 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(), AddressOfExpr::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(), lGetFunctionType(), lIsAllIntZeros(), lIsDifficultShiftAmount(), lIsVaryingFor(), lProcessPrintArg(), DeclStmt::Optimize(), BinaryExpr::Optimize(), SizeOfExpr::Print(), UnaryExpr::TypeCheck(), IfStmt::TypeCheck(), BinaryExpr::TypeCheck(), DoStmt::TypeCheck(), ForStmt::TypeCheck(), AssignExpr::TypeCheck(), SelectExpr::TypeCheck(), FunctionCallExpr::TypeCheck(), IndexExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), SwitchStmt::TypeCheck(), TypeCastExpr::TypeCheck(), AssertStmt::TypeCheck(), PtrDerefExpr::TypeCheck(), DeleteStmt::TypeCheck(), RefDerefExpr::TypeCheck(), AddressOfExpr::TypeCheck(), NewExpr::TypeCheck(), TypeConvertExpr(), and VectorMemberExpr::VectorMemberExpr().

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

This method should perform early optimizations of the expression (constant folding, etc.) and return a pointer to the resulting expression. If an error is encountered during optimization, NULL should be returned.

Implements ASTNode.

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

virtual void Expr::Print ( ) const
pure virtual
virtual Expr* Expr::TypeCheck ( )
pure virtual

This method should perform type checking of the expression and return a pointer to the resulting expression. If an error is encountered, NULL should be returned.

Implements ASTNode.

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

Referenced by lCreateBinaryOperatorCall().


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