Intel® Implicit SPMD Program Compiler (Intel® ISPC)  1.13.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
ASTNode Class Referenceabstract

Abstract base class for nodes in the abstract syntax tree (AST). More...

#include <ast.h>

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

Public Types

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 Member Functions

 ASTNode (SourcePos p, unsigned scid)
 
virtual ~ASTNode ()
 
virtual ASTNodeOptimize ()=0
 
virtual ASTNodeTypeCheck ()=0
 
virtual int EstimateCost () const =0
 
unsigned getValueID () const
 

Static Public Member Functions

static bool classof (ASTNode const *)
 

Public Attributes

SourcePos pos
 

Private Attributes

const unsigned char SubclassID
 

Detailed Description

Abstract base class for nodes in the abstract syntax tree (AST).

This class defines a basic interface that all abstract syntax tree (AST) nodes must implement. The base classes for both expressions (Expr) and statements (Stmt) inherit from this class.

Definition at line 49 of file ast.h.

Member Enumeration Documentation

◆ ASTNodeTy

An enumeration for keeping track of the concrete subclass of Value that is actually instantiated.

Enumerator
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 

Definition at line 80 of file ast.h.

Constructor & Destructor Documentation

◆ ASTNode()

ASTNode::ASTNode ( SourcePos  p,
unsigned  scid 
)
inline

Definition at line 52 of file ast.h.

References EstimateCost(), Optimize(), TypeCheck(), and ~ASTNode().

◆ ~ASTNode()

ASTNode::~ASTNode ( )
virtual

Definition at line 50 of file ast.cpp.

Referenced by ASTNode().

Member Function Documentation

◆ classof()

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

Definition at line 135 of file ast.h.

◆ EstimateCost()

virtual int ASTNode::EstimateCost ( ) const
pure 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.

Implemented in NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, RefDerefExpr, PtrDerefExpr, DeleteStmt, ReferenceExpr, AssertStmt, TypeCastExpr, PrintStmt, StmtList, ConstExpr, LabeledStmt, GotoStmt, SwitchStmt, DefaultStmt, CaseStmt, MemberExpr, ReturnStmt, IndexExpr, UnmaskedStmt, ForeachUniqueStmt, FunctionCallExpr, ForeachActiveStmt, ExprList, ForeachStmt, SelectExpr, ContinueStmt, BreakStmt, AssignExpr, ForStmt, BinaryExpr, DoStmt, UnaryExpr, IfStmt, DeclStmt, and ExprStmt.

Referenced by ASTNode(), ExprStmt::classof(), DeclStmt::classof(), IfStmt::classof(), UnaryExpr::classof(), DoStmt::classof(), BinaryExpr::classof(), ForStmt::classof(), AssignExpr::classof(), BreakStmt::classof(), ContinueStmt::classof(), SelectExpr::classof(), ForeachStmt::classof(), ExprList::classof(), ForeachActiveStmt::classof(), FunctionCallExpr::classof(), ForeachUniqueStmt::classof(), IndexExpr::classof(), UnmaskedStmt::classof(), ReturnStmt::classof(), MemberExpr::classof(), CaseStmt::classof(), DefaultStmt::classof(), SwitchStmt::classof(), GotoStmt::classof(), LabeledStmt::classof(), ConstExpr::classof(), StmtList::classof(), PrintStmt::classof(), TypeCastExpr::classof(), AssertStmt::classof(), ReferenceExpr::classof(), DeleteStmt::classof(), PtrDerefExpr::classof(), RefDerefExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), SyncExpr::classof(), NullPointerExpr::classof(), NewExpr::classof(), and lCostCallbackPre().

◆ getValueID()

unsigned ASTNode::getValueID ( ) const
inline

◆ Optimize()

virtual ASTNode* ASTNode::Optimize ( )
pure virtual

The Optimize() method should perform any appropriate early-stage optimizations on the node (e.g. constant folding). This method will be called after the node's children have already been optimized, and the caller will store the returned ASTNode * in place of the original node. This method should return NULL if an error is encountered during optimization.

Implemented in NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, DerefExpr, ReferenceExpr, TypeCastExpr, ConstExpr, LabeledStmt, GotoStmt, MemberExpr, IndexExpr, FunctionCallExpr, ExprList, SelectExpr, AssignExpr, BinaryExpr, UnaryExpr, DeclStmt, Expr, and Stmt.

Referenced by ASTNode(), lOptimizeNode(), and Optimize().

◆ TypeCheck()

virtual ASTNode* ASTNode::TypeCheck ( )
pure virtual

Type checking should be performed by the node when this method is called. In the event of an error, a NULL value may be returned. As with ASTNode::Optimize(), the caller should store the returned pointer in place of the original ASTNode *.

Implemented in NewExpr, NullPointerExpr, SyncExpr, FunctionSymbolExpr, SymbolExpr, SizeOfExpr, AddressOfExpr, RefDerefExpr, PtrDerefExpr, DeleteStmt, ReferenceExpr, AssertStmt, TypeCastExpr, PrintStmt, StmtList, ConstExpr, LabeledStmt, GotoStmt, SwitchStmt, DefaultStmt, CaseStmt, MemberExpr, ReturnStmt, IndexExpr, UnmaskedStmt, ForeachUniqueStmt, FunctionCallExpr, ForeachActiveStmt, ExprList, ForeachStmt, SelectExpr, ContinueStmt, BreakStmt, AssignExpr, ForStmt, BinaryExpr, DoStmt, UnaryExpr, IfStmt, DeclStmt, Expr, ExprStmt, and Stmt.

Referenced by ASTNode(), lTypeCheckNode(), and TypeCheck().

Member Data Documentation

◆ pos

SourcePos ASTNode::pos

All AST nodes must track the file position where they are defined.

Definition at line 76 of file ast.h.

Referenced by Module::AddFunctionDefinition(), Module::AddGlobalVariable(), MemberExpr::create(), FunctionEmitContext::CurrentLanesReturned(), Function::emitCode(), ExprStmt::EmitCode(), DeclStmt::EmitCode(), IfStmt::EmitCode(), DoStmt::EmitCode(), ForStmt::EmitCode(), BreakStmt::EmitCode(), ContinueStmt::EmitCode(), ForeachStmt::EmitCode(), ForeachActiveStmt::EmitCode(), ForeachUniqueStmt::EmitCode(), ReturnStmt::EmitCode(), CaseStmt::EmitCode(), DefaultStmt::EmitCode(), SwitchStmt::EmitCode(), GotoStmt::EmitCode(), LabeledStmt::EmitCode(), StmtList::EmitCode(), PrintStmt::EmitCode(), AssertStmt::EmitCode(), DeleteStmt::EmitCode(), IfStmt::emitMaskAllOn(), IfStmt::emitMaskMixed(), IfStmt::emitVaryingIf(), Function::GenerateIR(), Expr::GetBaseSymbol(), SelectExpr::GetType(), FunctionCallExpr::GetType(), BinaryExpr::GetValue(), AssignExpr::GetValue(), SelectExpr::GetValue(), FunctionCallExpr::GetValue(), TypeCastExpr::GetValue(), FunctionEmitContext::initLabelBBlocks(), InitSymbol(), lArrayToPointer(), lCheckIndicesVersusBounds(), lConstFoldBinaryArithOp(), lConstFoldBinaryIntOp(), lConstFoldBinaryLogicalOp(), lConstFoldBoolBinaryOp(), lCreateBinaryOperatorCall(), lDoTypeConv(), lEmitOpAssign(), lEmitPrePostIncDec(), lGetConstExprConstant(), lGetExprListConstant(), lProcessPrintArg(), lSwitchASTPreVisit(), lUniformValueToVarying(), UnaryExpr::Optimize(), BinaryExpr::Optimize(), SelectExpr::Optimize(), PossiblyResolveFunctionOverloads(), ExprStmt::Print(), DeclStmt::Print(), IfStmt::Print(), DoStmt::Print(), ForStmt::Print(), BreakStmt::Print(), ContinueStmt::Print(), ForeachStmt::Print(), ForeachActiveStmt::Print(), ForeachUniqueStmt::Print(), UnmaskedStmt::Print(), ReturnStmt::Print(), CaseStmt::Print(), DefaultStmt::Print(), SwitchStmt::Print(), StmtList::Print(), UnaryExpr::TypeCheck(), BinaryExpr::TypeCheck(), AssignExpr::TypeCheck(), SelectExpr::TypeCheck(), ForeachStmt::TypeCheck(), FunctionCallExpr::TypeCheck(), ForeachUniqueStmt::TypeCheck(), LabeledStmt::TypeCheck(), TypeCastExpr::TypeCheck(), DeleteStmt::TypeCheck(), AddressOfExpr::TypeCheck(), and TypeConvertExpr().

◆ SubclassID

const unsigned char ASTNode::SubclassID
private

Definition at line 50 of file ast.h.

Referenced by getValueID().


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