Intel SPMD Program Compiler  1.9.1
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
SymbolExpr Class Reference

Expression representing a symbol reference in the program. More...

#include <expr.h>

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

Public Member Functions

 SymbolExpr (Symbol *s, SourcePos p)
 
llvm::Value * GetValue (FunctionEmitContext *ctx) const
 
llvm::Value * GetLValue (FunctionEmitContext *ctx) const
 
const TypeGetType () const
 
const TypeGetLValueType () const
 
SymbolGetBaseSymbol () const
 
ExprTypeCheck ()
 
ExprOptimize ()
 
void Print () const
 
int EstimateCost () const
 
- Public Member Functions inherited from Expr
 Expr (SourcePos p, unsigned scid)
 
virtual llvm::Constant * GetConstant (const Type *type) const
 
- Public Member Functions inherited from ASTNode
 ASTNode (SourcePos p, unsigned scid)
 
virtual ~ASTNode ()
 
unsigned getValueID () const
 

Static Public Member Functions

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

Private Attributes

Symbolsymbol
 

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

Expression representing a symbol reference in the program.

Definition at line 668 of file expr.h.

Constructor & Destructor Documentation

SymbolExpr::SymbolExpr ( Symbol s,
SourcePos  p 
)

Definition at line 7930 of file expr.cpp.

References symbol.

Member Function Documentation

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

Definition at line 672 of file expr.h.

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

Definition at line 673 of file expr.h.

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

int SymbolExpr::EstimateCost ( ) const
virtual

Estimate the execution cost of the node (not including the cost of the children. The value returned should be based on the COST_* enumerant values defined in ispc.h.

Implements ASTNode.

Definition at line 8001 of file expr.cpp.

Symbol * SymbolExpr::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 from Expr.

Definition at line 7970 of file expr.cpp.

References symbol.

llvm::Value * SymbolExpr::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 from Expr.

Definition at line 7949 of file expr.cpp.

References FunctionEmitContext::SetDebugPos(), Symbol::storagePtr, and symbol.

const Type * SymbolExpr::GetLValueType ( ) const
virtual

Returns the type of the value returned by GetLValueType(); this should be a pointer type of some sort (uniform or varying).

Reimplemented from Expr.

Definition at line 7958 of file expr.cpp.

References Type::GetReferenceTarget(), PointerType::GetUniform(), symbol, and Symbol::type.

const Type * SymbolExpr::GetType ( ) const
virtual

Returns the Type of the expression.

Implements Expr.

Definition at line 7976 of file expr.cpp.

References symbol, and Symbol::type.

Referenced by Optimize(), and Print().

llvm::Value * SymbolExpr::GetValue ( FunctionEmitContext ctx) const
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.

Implements Expr.

Definition at line 7937 of file expr.cpp.

References FunctionEmitContext::LoadInst(), Symbol::name, FunctionEmitContext::SetDebugPos(), Symbol::storagePtr, and symbol.

Expr * SymbolExpr::Optimize ( )
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 Expr.

Definition at line 7988 of file expr.cpp.

References AssertPos, Symbol::constValue, GetType(), and symbol.

void SymbolExpr::Print ( ) const
virtual

Prints the expression to standard output (used for debugging).

Implements Expr.

Definition at line 8009 of file expr.cpp.

References GetType(), Symbol::name, SourcePos::Print(), and symbol.

Expr * SymbolExpr::TypeCheck ( )
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 Expr.

Definition at line 7982 of file expr.cpp.

Member Data Documentation

Symbol* SymbolExpr::symbol
private

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