Intel® Implicit SPMD Program Compiler (Intel® ISPC)
1.13.0
|
Abstract base class for nodes in the abstract syntax tree (AST). More...
#include <ast.h>
Public Member Functions | |
ASTNode (SourcePos p, unsigned scid) | |
virtual | ~ASTNode () |
virtual ASTNode * | Optimize ()=0 |
virtual ASTNode * | TypeCheck ()=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 |
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.
enum ASTNode::ASTNodeTy |
An enumeration for keeping track of the concrete subclass of Value that is actually instantiated.
|
inline |
Definition at line 52 of file ast.h.
References EstimateCost(), Optimize(), TypeCheck(), and ~ASTNode().
|
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().
|
inline |
Return an ID for the concrete type of this object. This is used to implement the classof checks. This should not be used for any other purpose, as the values may change as ISPC evolves
Definition at line 133 of file ast.h.
References SubclassID.
Referenced by Expr::classof(), Stmt::classof(), 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(), DerefExpr::classof(), PtrDerefExpr::classof(), RefDerefExpr::classof(), AddressOfExpr::classof(), SizeOfExpr::classof(), SymbolExpr::classof(), FunctionSymbolExpr::classof(), SyncExpr::classof(), NullPointerExpr::classof(), NewExpr::classof(), StructMemberExpr::classof(), and VectorMemberExpr::classof().
|
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().
|
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().
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().
|
private |
Definition at line 50 of file ast.h.
Referenced by getValueID().