Intel SPMD Program Compiler  1.9.2
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
Symbol * Expr::GetBaseSymbol ( ) const
virtual
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(), classof(), ExprList::classof(), ConstExpr::classof(), TypeCastExpr::classof(), AddressOfExpr::classof(), FunctionSymbolExpr::classof(), NullPointerExpr::classof(), 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 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().

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 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(), 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

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().

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

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