Intel SPMD Program Compiler  1.9.1
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes | List of all members
MemberExpr Class Referenceabstract

Expression representing member selection ("foo.bar"). More...

#include <expr.h>

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

Public Member Functions

llvm::Value * GetValue (FunctionEmitContext *ctx) const
 
llvm::Value * GetLValue (FunctionEmitContext *ctx) const
 
const TypeGetType () const
 
SymbolGetBaseSymbol () const
 
void Print () const
 
ExprOptimize ()
 
ExprTypeCheck ()
 
int EstimateCost () const
 
virtual int getElementNumber () const =0
 
virtual const TypegetElementType () const =0
 
std::string getCandidateNearMatches () const
 
 MemberExpr (Expr *expr, const char *identifier, SourcePos pos, SourcePos identifierPos, bool derefLValue, unsigned scid)
 
- Public Member Functions inherited from Expr
 Expr (SourcePos p, unsigned scid)
 
virtual const TypeGetLValueType () const
 
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 MemberExprcreate (Expr *expr, const char *identifier, SourcePos pos, SourcePos identifierPos, bool derefLvalue)
 
static bool classof (MemberExpr 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

Exprexpr
 
std::string identifier
 
const SourcePos identifierPos
 
bool dereferenceExpr
 
- Public Attributes inherited from ASTNode
SourcePos pos
 

Protected Attributes

const Typetype
 
const TypelvalueType
 

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 member selection ("foo.bar").

This will also be overloaded to deal with swizzles.

Definition at line 341 of file expr.h.

Constructor & Destructor Documentation

MemberExpr::MemberExpr ( Expr expr,
const char *  identifier,
SourcePos  pos,
SourcePos  identifierPos,
bool  derefLValue,
unsigned  scid 
)

Definition at line 5177 of file expr.cpp.

References dereferenceExpr, expr, identifier, lvalueType, and type.

Member Function Documentation

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

Definition at line 347 of file expr.h.

static bool MemberExpr::classof ( ASTNode const *  N)
inlinestatic
MemberExpr * MemberExpr::create ( Expr expr,
const char *  identifier,
SourcePos  pos,
SourcePos  identifierPos,
bool  derefLvalue 
)
static
int MemberExpr::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 5300 of file expr.cpp.

References COST_GATHER, COST_SIMPLE_ARITH_LOGIC_OP, Expr::GetLValueType(), Type::IsVaryingType(), and lvalueType.

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

References expr, and Expr::GetBaseSymbol().

Referenced by GetValue().

std::string MemberExpr::getCandidateNearMatches ( ) const

There is no structure member with the name we've got in "identifier". Use the approximate string matching routine to see if the identifier is a minor misspelling of one of the ones that is there.

Definition at line 5326 of file expr.cpp.

References expr, StructType::GetElementCount(), StructType::GetElementName(), Expr::GetType(), identifier, and MatchStrings().

Referenced by StructMemberExpr::getElementNumber(), and StructMemberExpr::GetType().

int MemberExpr::getElementNumber ( ) const
pure virtual

Implemented in VectorMemberExpr, and StructMemberExpr.

Definition at line 5249 of file expr.cpp.

Referenced by GetLValue(), and GetValue().

virtual const Type* MemberExpr::getElementType ( ) const
pure virtual

Implemented in VectorMemberExpr, and StructMemberExpr.

llvm::Value * MemberExpr::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.

Reimplemented in VectorMemberExpr.

Definition at line 5255 of file expr.cpp.

References FunctionEmitContext::AddElementOffset(), AssertPos, dereferenceExpr, Module::errorCount, expr, getElementNumber(), Expr::GetLValue(), Expr::GetLValueType(), Expr::GetType(), Expr::GetValue(), lAddVaryingOffsetsIfNeeded(), m, and FunctionEmitContext::SetDebugPos().

Referenced by VectorMemberExpr::GetLValue(), and GetValue().

const Type * MemberExpr::GetType ( ) const
virtual

Returns the Type of the expression.

Implements Expr.

Reimplemented in VectorMemberExpr, and StructMemberExpr.

Definition at line 5237 of file expr.cpp.

Referenced by GetValue(), and Print().

llvm::Value * MemberExpr::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.

Reimplemented in VectorMemberExpr.

Definition at line 5188 of file expr.cpp.

References FunctionEmitContext::AddElementOffset(), FunctionEmitContext::AllocaInst(), AssertPos, Globals::ctx, Module::errorCount, expr, g, GetBaseSymbol(), getElementNumber(), GetLValue(), Expr::GetLValueType(), Expr::GetType(), GetType(), PointerType::GetUniform(), Expr::GetValue(), identifier, LLVMGetName(), LLVMMaskAllOn, Type::LLVMType(), lMaskForSymbol(), FunctionEmitContext::LoadInst(), lvalueType, m, FunctionEmitContext::SetDebugPos(), and FunctionEmitContext::StoreInst().

Referenced by VectorMemberExpr::GetValue().

Expr * MemberExpr::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 5294 of file expr.cpp.

References expr.

void MemberExpr::Print ( ) const
virtual

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

Implements Expr.

Definition at line 5310 of file expr.cpp.

References expr, GetType(), identifier, Expr::Print(), and SourcePos::Print().

Expr * MemberExpr::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 5288 of file expr.cpp.

References expr.

Referenced by create().

Member Data Documentation

bool MemberExpr::dereferenceExpr

Indicates whether the expression should be dereferenced before the member is found. (i.e. this is true if the MemberExpr was a '->' operator, and is false if it was a '.' operator.

Definition at line 376 of file expr.h.

Referenced by GetLValue(), StructMemberExpr::GetLValueType(), VectorMemberExpr::GetLValueType(), StructMemberExpr::getStructType(), VectorMemberExpr::GetValue(), lCheckAllOffSafety(), and MemberExpr().

Expr* MemberExpr::expr
std::string MemberExpr::identifier
const SourcePos MemberExpr::identifierPos

Definition at line 368 of file expr.h.

Referenced by StructMemberExpr::getElementNumber(), and StructMemberExpr::GetType().

const Type * MemberExpr::lvalueType
mutableprotected
const Type* MemberExpr::type
mutableprotected

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