Intel SPMD Program Compiler  1.12.0
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 287 of file expr.h.

Constructor & Destructor Documentation

◆ IndexExpr()

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

Definition at line 3835 of file expr.cpp.

References baseExpr, index, lvalueType, and type.

Member Function Documentation

◆ classof() [1/2]

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

Definition at line 291 of file expr.h.

◆ classof() [2/2]

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

◆ EstimateCost()

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

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

◆ GetBaseSymbol()

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

References baseExpr, and Expr::GetBaseSymbol().

Referenced by GetValue().

◆ GetLValue()

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

◆ GetLValueType()

const Type * IndexExpr::GetLValueType ( ) const
virtual

◆ GetType()

const Type * IndexExpr::GetType ( ) const
virtual

◆ GetValue()

llvm::Value * IndexExpr::GetValue ( FunctionEmitContext ctx) const
virtual

◆ Optimize()

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

References baseExpr, and index.

◆ Print()

void IndexExpr::Print ( ) const
virtual

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

Implements Expr.

Definition at line 4325 of file expr.cpp.

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

◆ TypeCheck()

Expr * IndexExpr::TypeCheck ( )
virtual

Member Data Documentation

◆ baseExpr

Expr* IndexExpr::baseExpr

◆ index

Expr * IndexExpr::index

◆ lvalueType

const PointerType* IndexExpr::lvalueType
mutableprivate

Definition at line 309 of file expr.h.

Referenced by GetLValueType(), and IndexExpr().

◆ type

const Type* IndexExpr::type
mutableprivate

Definition at line 308 of file expr.h.

Referenced by GetType(), IndexExpr(), and lVaryingStructHasUniformMember().


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