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

Expression representing indexing into something with an integer offset. More...

#include <expr.h>

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

Public Member Functions

 IndexExpr (Expr *baseExpr, Expr *index, SourcePos p)
 
llvm::Value * GetValue (FunctionEmitContext *ctx) const
 
llvm::Value * GetLValue (FunctionEmitContext *ctx) const
 
const TypeGetType () const
 
const TypeGetLValueType () const
 
SymbolGetBaseSymbol () const
 
void Print () const
 
ExprOptimize ()
 
ExprTypeCheck ()
 
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 (IndexExpr 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 *)
 

Public Attributes

ExprbaseExpr
 
Exprindex
 
- Public Attributes inherited from ASTNode
SourcePos pos
 

Private Attributes

const Typetype
 
const PointerTypelvalueType
 

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
}
 

Detailed Description

Expression representing indexing into something with an integer offset.

This is used for both array indexing and indexing into VectorTypes.

Definition at line 309 of file expr.h.

Constructor & Destructor Documentation

IndexExpr::IndexExpr ( Expr baseExpr,
Expr index,
SourcePos  p 
)

Definition at line 4122 of file expr.cpp.

References baseExpr, index, lvalueType, and type.

Member Function Documentation

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

Definition at line 313 of file expr.h.

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

Definition at line 314 of file expr.h.

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

int IndexExpr::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 4658 of file expr.cpp.

References baseExpr, COST_GATHER, COST_LOAD, Expr::GetType(), index, and Type::IsVaryingType().

Symbol * IndexExpr::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 4358 of file expr.cpp.

References baseExpr, and Expr::GetBaseSymbol().

Referenced by GetValue().

llvm::Value * IndexExpr::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 4439 of file expr.cpp.

References AssertPos, baseExpr, Module::errorCount, FunctionEmitContext::GetElementPtrInst(), Expr::GetLValue(), Expr::GetLValueType(), GetLValueType(), Type::GetReferenceTarget(), Expr::GetType(), PointerType::GetUniform(), Expr::GetValue(), index, lAddVaryingOffsetsIfNeeded(), lCheckIndicesVersusBounds(), lConvertPtrToSliceIfNeeded(), LLVMGetName(), LLVMInt32(), m, and FunctionEmitContext::SetDebugPos().

Referenced by GetValue().

const Type * IndexExpr::GetLValueType ( ) const
virtual
const Type * IndexExpr::GetType ( ) const
virtual
llvm::Value * IndexExpr::GetValue ( FunctionEmitContext ctx) const
virtual
Expr * IndexExpr::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 4577 of file expr.cpp.

References baseExpr, and index.

void IndexExpr::Print ( ) const
virtual

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

Implements Expr.

Definition at line 4677 of file expr.cpp.

References baseExpr, GetType(), index, Expr::Print(), and SourcePos::Print().

Expr * IndexExpr::TypeCheck ( )
virtual

Member Data Documentation

Expr* IndexExpr::baseExpr
Expr * IndexExpr::index
const PointerType* IndexExpr::lvalueType
mutableprivate

Definition at line 333 of file expr.h.

Referenced by GetLValueType(), and IndexExpr().

const Type* IndexExpr::type
mutableprivate

Definition at line 332 of file expr.h.

Referenced by GetType(), and IndexExpr().


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