Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
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 std::pair< llvm::Constant *, bool > GetStorageConstant (const Type *type) const
 
virtual std::pair< llvm::Constant *, bool > 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 328 of file expr.h.

Constructor & Destructor Documentation

◆ MemberExpr()

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

Definition at line 4882 of file expr.cpp.

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

Member Function Documentation

◆ classof() [1/2]

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

Definition at line 333 of file expr.h.

◆ classof() [2/2]

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

◆ create()

MemberExpr * MemberExpr::create ( Expr expr,
const char *  identifier,
SourcePos  pos,
SourcePos  identifierPos,
bool  derefLvalue 
)
static

◆ EstimateCost()

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

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

◆ GetBaseSymbol()

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

References expr, and Expr::GetBaseSymbol().

Referenced by GetValue().

◆ getCandidateNearMatches()

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

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

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

◆ getElementNumber()

int MemberExpr::getElementNumber ( ) const
pure virtual

Implemented in VectorMemberExpr, and StructMemberExpr.

Definition at line 4937 of file expr.cpp.

Referenced by GetLValue(), and GetValue().

◆ getElementType()

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

Implemented in VectorMemberExpr, and StructMemberExpr.

◆ GetLValue()

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.

Definition at line 4939 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::classof(), VectorMemberExpr::GetLValue(), and GetValue().

◆ GetType()

const Type * MemberExpr::GetType ( ) const
virtual

Returns the Type of the expression.

Implements Expr.

Definition at line 4933 of file expr.cpp.

Referenced by GetValue(), and Print().

◆ GetValue()

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.

Definition at line 4890 of file expr.cpp.

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

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

◆ Optimize()

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

References expr.

◆ Print()

void MemberExpr::Print ( ) const
virtual

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

Implements Expr.

Definition at line 4978 of file expr.cpp.

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

◆ TypeCheck()

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

References expr.

Referenced by create().

Member Data Documentation

◆ dereferenceExpr

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 361 of file expr.h.

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

◆ expr

Expr* MemberExpr::expr

◆ identifier

std::string MemberExpr::identifier

◆ identifierPos

const SourcePos MemberExpr::identifierPos

Definition at line 353 of file expr.h.

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

◆ lvalueType

const Type * MemberExpr::lvalueType
mutableprotected

◆ type

const Type* MemberExpr::type
mutableprotected

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